/**
 *
 */
package gemini.basic.dao.impl;

import gemini.basic.dao.CartStatusDao;
import gemini.basic.dao.GmnDao;
import gemini.basic.model.CartStatus;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 *
 *
 */
public class CartStatusDaoImpl extends HibernateDaoSupport implements CartStatusDao {

	private GmnDao gmnDao;

	public void setGmnDao(GmnDao gmnDao) {
		this.gmnDao = gmnDao;
	}

	@Override
	public List<CartStatus> getAll() {

		DetachedCriteria dtCri = DetachedCriteria.forClass(CartStatus.class);

		List<Object> cartList = gmnDao.findByCriteria(dtCri);
		List<CartStatus> result = null;

		if (cartList != null) {
			result = new ArrayList<CartStatus>(cartList.size());

			for (Object ob : cartList) {
				result.add((CartStatus) ob);
			}
		}

		return result;
	}
	
	@Override
	public boolean deleteCartStatus( CartStatus cartStatus){
		getHibernateTemplate().delete(cartStatus);
		return true;
	}

	@Override
	public CartStatus saveOrUpdate(CartStatus cartStatus,boolean flush) {
		CartStatus result = null;
		if (flush) {
			result = (CartStatus) gmnDao.saveOrUpdateAndFlush(cartStatus);
		} else {
			result = (CartStatus) gmnDao.saveOrUpdate(cartStatus);
		}
		return result;
		
	}

}
